﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Prism.Interfaces;
using Microsoft.Practices.Unity;
using EmployeeModule.EmployeeChooser;
using EmployeeModule.EmployeeMain;
using EmployeeModule.EmployeeDetail;
using System.Windows;

namespace EmployeeModule
{
    public class EmployeeModule : IModule
    {
        private IUnityContainer container;

        public EmployeeModule(IUnityContainer container)
        {
            this.container = container;
        }

        public void Initialize()
        {
            RegisterViewsAndServices();

            IEmployeeMainController controller = container.Resolve<IEmployeeMainController>();
            controller.Show();
        }

        private void RegisterViewsAndServices()
        {
            // mainview is a singleton 
            container.RegisterType<IEmployeeMainView, EmployeeMainView>(new ContainerControlledLifetimeManager());
            container.RegisterType<IEmployeeMainController, EmployeeMainController>(new ContainerControlledLifetimeManager());

            container.RegisterType<IEmployeeDetailView, EmployeeDetailView>();
            container.RegisterType<IEmployeeDetailController, EmployeeDetailController>();

            container.RegisterType<IEmployeeChooserController, EmployeeChooserController>();
            container.RegisterType<IEmployeeChooserView, EmployeeChooserView>();
        }
    }
}
